package cn.chair.entity;

import life.innovation.annotation.orm.Entity;
import life.innovation.annotation.orm.Id;
import life.innovation.model.BaseModel;

import java.util.Date;

@Entity
public class Payment extends BaseModel {

    public static final int STATUS_CANCELLED = 0;
    public static final int STATUS_ACTIVE = 1;
    public static final int STATUS_PENDING = 2;
//    public static final int STATUS_UNRECONCILED = 3;

    public static final int RECONCILIATION_EQUAL = 1;
    public static final int RECONCILIATION_NOT_EQUAL = 0;
    public static final int RECONCILIATION_PENDING = 2;

    public static final int NO_PREFIX_ORDER = 1; // 订单
    public static final int NO_PREFIX_RECHARGE = 2; // 会员充值
    public static final int NO_PREFIX_REVERSAL = 3; // 退单
    
//    public static final int SETTLEMENT_STATUS_FAILED = 0;//失败
    public static final int SETTLEMENT_STATUS_SUCCESS = 1;//已结算过
    public static final int SETTLEMENT_STATUS_PENDING = 2;//待结算
    public static final int SETTLEMENT_STATUS_SUCCESS_MISSING = 3;
    public static final int SETTLEMENT_STATUS_FAILED_EXTRA = 4;
    public static final int SETTLEMENT_STATUS_FAILED_DIFF = 5;

    @Id
    private int id;
    private String merchantId;
    private String orderNo;
    private int orderId;
    private Integer refPaymentId;
    private int paymentTypeId;
    private int paymentTypeNo;
    private Integer settlementStatus;
    private String transNo;
    private int transType;
    private double amount;
    private double fee;
    private double refundAmount;
    private Integer customerId ;
    private Date transTime;
    private Date createdAt;
    private Integer status;

    public Payment() {
        this.createdAt = new Date();
        this.transTime = new Date();
        this.settlementStatus = SETTLEMENT_STATUS_PENDING;
        this.status = STATUS_PENDING;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(String merchantId) {
        this.merchantId = merchantId;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }

    public Integer getRefPaymentId() {
        return refPaymentId;
    }

    public void setRefPaymentId(Integer refPaymentId) {
        this.refPaymentId = refPaymentId;
    }

    public int getPaymentTypeId() {
        return paymentTypeId;
    }

    public void setPaymentTypeId(int paymentTypeId) {
        this.paymentTypeId = paymentTypeId;
    }

    public int getPaymentTypeNo() {
        return paymentTypeNo;
    }

    public void setPaymentTypeNo(int paymentTypeNo) {
        this.paymentTypeNo = paymentTypeNo;
    }

    public Integer getSettlementStatus() {
        return settlementStatus;
    }

    public void setSettlementStatus(Integer settlementStatus) {
        this.settlementStatus = settlementStatus;
    }

    public String getTransNo() {
        return transNo;
    }

    public void setTransNo(String transNo) {
        this.transNo = transNo;
    }

    public int getTransType() {
        return transType;
    }

    public void setTransType(int transType) {
        this.transType = transType;
    }

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public double getFee() {
        return fee;
    }

    public void setFee(double fee) {
        this.fee = fee;
    }

    public double getRefundAmount() {
        return refundAmount;
    }

    public void setRefundAmount(double refundAmount) {
        this.refundAmount = refundAmount;
    }

    public Integer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Integer customerId) {
        this.customerId = customerId;
    }

    public Date getTransTime() {
        return transTime;
    }

    public void setTransTime(Date transTime) {
        this.transTime = transTime;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(amount);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + paymentTypeId;
		result = prime * result + ((transNo == null) ? 0 : transNo.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Payment other = (Payment) obj;
		if (Double.doubleToLongBits(amount) != Double.doubleToLongBits(other.amount))
			return false;
		if (paymentTypeId != other.paymentTypeId)
			return false;
		if (transNo == null) {
			if (other.transNo != null)
				return false;
		} else if (!transNo.equals(other.transNo))
			return false;
		return true;
	}
    
}
